<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link type="text/css" rel="stylesheet" href="__PUBLIC__/css/style.css" />
    <!--[if IE 6]>
    <script src="js/iepng.js" type="text/javascript"></script>
        <script type="text/javascript">
           EvPNG.fix('div, ul, img, li, input, a'); 
        </script>
    <![endif]-->
    <script type="text/javascript" src="__PUBLIC__/address/js/jquery-1.11.0.min.js"></script>
<title>数码商城个人中心</title>

  <style>
      .eidt{
        border:1px solid red;
        width: 400px;
        height: 200px;
        position:fixed;
        background:white;
        left:50%;
        top:40%;
        display:none
      }
      .addclass{
        border:1px solid red;
      }
  </style>
</head>
<body>  
<!--Begin Header Begin-->
<include file="./Public/file/top.html" />
<!--End Header End--> 
<div class="i_bg bg_color">
    <!--Begin 用户中心 Begin -->
  <div class="m_content">
      <include file="./Zxshop/Home/View/Member/left.html" />
    <div class="m_right">
            <div class="mem_tit">收货地址(最多只能添加6个地址)</div>
        <foreach name="list" item="val">
              <div class="address {$val['status']==1?"addclass":""}" style="width: 420px;height:190px;float: left;margin-left: 20px;" id="add{$val['id']}">
              <div class="a_close"><a href="javascript:void(0)"><img src="__PUBLIC__/images/a_close.png" onclick="do_Del({$val['id']})" /></a></div>
              <table border="0" class="add_t" align="center" style="width:98%; margin:10px auto;" cellspacing="0" cellpadding="0" id="table{$val['id']}">
                  <tr>
                    <td align="right" width="80">收货人姓名：</td>
                    <td>{$val['linkman']}</td>
                  </tr>
                  <tr>
                    <td align="right">详细地址：</td>
                    <td>{$val['address']}</td>
                  </tr>
                  <tr>
                    <td align="right">手机：</td>
                    <td>{$val['phone']}</td>
                  </tr>
                  <tr>
                    <td align="right">邮编：</td>
                    <td>{$val['code']}</td>
                  </tr>
                  <input type="hidden" value="{$val['id']}">
                  <input type="hidden" value="{$val['uid']}">
                </table>
                <p align="right" id="p{$val['id']}">
                  <a href="javascript:void(0)" onclick="status({$val['id']})" style="color:#ff4e00;">设为默认</a>　
                  <a href="javascript:void(0)" onclick="edit({$val['id']})" style="color:#ff4e00;">编辑</a>
                </p>
            </div>
        </foreach>
        <div class="eidt" >
          <form action="{:U('Home/member/member_eidt')}" method="post">
            <table style="margin-top: 30px">
                <tr>
                  <td>收货人姓名：</td>
                  <td><input type="text" name="linkman" value="{$val['linkman']}"></td>
                </tr>
                <tr>
                  <td>详细地址：</td>
                  <td><input type="text" name="address"></td>
                </tr>
                <tr>
                  <td>手机：</td>
                  <td><input type="text" name="phone"></td>
                </tr>
                <tr>
                  <td>邮编：</td>
                  <td><input type="text" name="code"></td>
                </tr>
            </table>
            <input type="submit" value="保存" style="margin-left: 150px">
            <input class="cancel" type="button" value="取消">
            <input type="hidden" name="id" class="aid">
            <input type="hidden" name="uid" class="uid">
          </form>
        </div>
        
          <div style="clear:both;"></div>

          <if condition="(6-$sum) gt 0">
            <p align="right">
                <a href="javascript:void(0)" class="add_b" onclick="edit()">添加地址</a>
            </p>
          </if>
            
        </div>
    </div>
  <!--End 用户中心 End--> 
    <!--Begin Footer Begin -->
    <include file="./Public/file/bottom.html" />
    <!--End Footer End -->    
</div>
  
</body>

<script>
          function status(id){
              $("div").removeClass("addclass");
              
              var sid = '#add'+id;
              $(sid).addClass("addclass");
              $.get(
                  "{:U('home/member/member_status')}",
                  {'id':id,'status':1}
                )};
            

            function do_Del(did){
              var id = "#add"+did;
              if(confirm("确定要删除？")){
                $(id).remove();
                $.get(
                    "{:U('home/member/member_del')}",
                    {'id':did},
                    function($data){
                      window.location.reload();
                    }
                  );
              }
            }

        function edit(id){
           $('<div class="blank"></div>').css({
                'width':$(window).width(),
                'height':$(window).height(),
                'background':'rgba(0,0,0,0.3)',
                'position':'fixed',
                'left':0,
                'top':0,
              }).appendTo($(document.body));
              init(id);
        }

          function init(id){
            $('.eidt').css({
              'margin-left':function(){
                return -(Math.ceil($(this).width() / 2));
              },
              'margin-top':function(){
                return -(Math.ceil($(this).height() / 2));
              },
              'display':'block',
            }).appendTo($(document.body));
            var id = "#table"+id;
            
            var v1 = $(id+" td").eq(1).text();
            var v2 = $(id+" td").eq(3).text();
            var v3 = $(id+" td").eq(5).text();
            var v4 = $(id+" td").eq(7).text();
            // alert(v4);
            var v5 = $(id+" input:hidden").eq(0).val();
            var v6 = $(id+" input:hidden").eq(1).val()
            
            $('.eidt table td input:eq(0)').val(v1);
            $('.eidt table td input:eq(1)').val(v2);
            $('.eidt table td input:eq(2)').val(v3);
            $('.eidt table td input:eq(3)').val(v4);
            $('.aid').val(v5);
            $('.uid').val(v6);
          }

          $('.cancel').click(function(){
              $('.eidt').css('display','none');
              $('.blank').remove();
          });
          </script>
<!--[if IE 6]>
<script src="//letskillie6.googlecode.com/svn/trunk/2/zh_CN.js"></script>
<![endif]-->
</html>
